/* 
 * File:   tree_view_context_menu.cpp
 * Author: jolo
 * 
 * Created on: 12. Oktober 2011, 14:04
 * Lincense: New BSD License (The BSD 2-Clause License)
 */

#include "tree_view_context_menu.hpp"

#include "tree_view.hpp"

namespace widgets
{

    tree_view_context_menu::tree_view_context_menu(tree_view* v, tree_model* m, entity_item* itm)
    : menu(v), v_(v), m_(m), itm_(itm)
    {
        create_a_ = new QAction(tr("Create..."), this);
        edit_a_ = new QAction(tr("Edit..."), this);
        delete_a_ = new QAction(tr("Delete"), this);
        
        connect(create_a_, SIGNAL(triggered()), this, SLOT(on_create_request()));
        connect(edit_a_, SIGNAL(triggered()), this, SLOT(on_edit_request()));
        connect(delete_a_, SIGNAL(triggered()), this, SLOT(on_delete_request()));
        
        addAction(create_a_);
        addAction(edit_a_);
        insertSeparator(delete_a_);
        addAction(delete_a_);
    }

    tree_view_context_menu::~tree_view_context_menu()
    {
    }
    
    void tree_view_context_menu::on_create_request() {
        emit create_request(itm_);
    }
    
    void tree_view_context_menu::on_edit_request() {
        emit edit_request(itm_);
    }
    
    void tree_view_context_menu::on_delete_request() {
        emit delete_request(itm_);
    }
}